/*     */ package eos.moe.dragoncore;
/*     */ import java.awt.image.BufferedImage;
/*     */ import java.io.ByteArrayInputStream;
/*     */ import java.io.Closeable;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.net.URL;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Base64;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.concurrent.CopyOnWriteArrayList;
/*     */ import java.util.concurrent.ExecutorService;
/*     */ import java.util.concurrent.Executors;
/*     */ import javax.imageio.ImageIO;
/*     */ import net.minecraft.client.Minecraft;
/*     */ import net.minecraft.client.renderer.GlStateManager;
/*     */ import net.minecraft.client.renderer.texture.ITextureObject;
/*     */ import net.minecraft.client.renderer.texture.ITickable;
/*     */ import net.minecraft.client.renderer.texture.PngSizeInfo;
/*     */ import net.minecraft.client.renderer.texture.SimpleTexture;
/*     */ import net.minecraft.client.renderer.texture.TextureManager;
/*     */ import net.minecraft.client.renderer.texture.TextureUtil;
/*     */ import net.minecraft.client.resources.IResource;
/*     */ import net.minecraft.client.resources.IResourceManager;
/*     */ import net.minecraft.util.ResourceLocation;
/*     */ import net.minecraft.util.Tuple;
/*     */ import net.minecraftforge.fml.relauncher.ReflectionHelper;
/*     */ import org.apache.commons.io.IOUtils;
/*     */ import org.apache.commons.lang3.math.NumberUtils;
/*     */ 
/*     */ public class hw extends AbstractTexture implements ITickable {
/*     */   private static SimpleTexture c;
/*     */   public String r;
/*     */   public boolean f;
/*     */   public boolean s;
/*     */   private boolean m;
/*     */   private List<eos/moe/dragoncore/cu> l;
/*     */   private int t;
/*     */   private long d;
/*     */   public bp z;
/*     */   public static ExecutorService i;
/*     */   
/*     */   public static void t() {
/*  46 */     ResourceLocation a = new ResourceLocation("dragoncore", "alpha0.png");
/*  47 */     c = new SimpleTexture(a);
/*  48 */     Minecraft.func_71410_x().func_110434_K().func_110579_a(a, (ITextureObject)c);
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public hw(String str) {
/*  54 */     this.l = new CopyOnWriteArrayList<>();
/*  55 */     this.r = str;
/*  56 */     this.m = true;
/*  57 */     if (this.r.isEmpty()) {
/*  58 */       this.f = true;
/*     */     }
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public void func_110551_a(IResourceManager iResourceManager) throws IOException {
/*  65 */     if (this.r.startsWith("data:image/") && this.r.contains(",")) {
/*  66 */       i.submit(() -> {
/*     */             InputStream inputStream = null;
/*     */             try {
/*     */               String[] arrayOfString = this.r.split(",", 2);
/*     */               inputStream = new ByteArrayInputStream(Base64.getDecoder().decode(arrayOfString[1]));
/*     */               v(inputStream);
/*  72 */             } catch (IOException iOException) {
/*     */               iOException.printStackTrace();
/*     */               this.f = true;
/*     */             } finally {
/*     */               IOUtils.closeQuietly(inputStream);
/*     */             } 
/*     */           });
/*  79 */     } else if (this.r.startsWith("http")) {
/*  80 */       URL uRL = new URL(this.r);
/*  81 */       i.submit(() -> {
/*     */             InputStream inputStream = null;
/*     */             try {
/*     */               inputStream = new ByteArrayInputStream(id.v(uRL.toURI()));
/*     */               v(inputStream);
/*  86 */             } catch (IOException|java.net.URISyntaxException exception) {
/*     */               exception.printStackTrace();
/*     */               
/*     */               this.f = true;
/*     */             } finally {
/*     */               IOUtils.closeQuietly(inputStream);
/*     */             } 
/*     */           });
/*     */     } else {
/*     */       try {
/*  96 */         IResource iResource = iResourceManager.func_110536_a(new ResourceLocation("dragoncore", this.r));
/*  97 */         if (!iResource.func_110528_c()) {
/*  98 */           InputStream inputStream = iResource.func_110527_b();
/*  99 */           i.submit(() -> {
/*     */                 try {
/*     */                   v(inputStream);
/* 102 */                 } catch (IOException iOException) {
/*     */                   iOException.printStackTrace();
/*     */                   this.f = true;
/*     */                 } finally {
/*     */                   IOUtils.closeQuietly((Closeable)iResource);
/*     */                 } 
/*     */               });
/*     */         } else {
/*     */           try {
/* 111 */             v(iResource);
/* 112 */           } catch (IOException iOException) {
/* 113 */             iOException.printStackTrace();
/* 114 */             this.f = true;
/*     */           } finally {
/* 116 */             IOUtils.closeQuietly((Closeable)iResource);
/*     */           } 
/*     */         } 
/* 119 */       } catch (Exception exception) {
/* 120 */         this.f = true;
/* 121 */         throw exception;
/*     */       } 
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void func_110550_d() {
/* 158 */     if (this.z != null) {
/* 159 */       GlStateManager.func_179144_i(func_110552_b());
/* 160 */       this.z.func_94219_l();
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void loadPng(InputStream inputStream) throws IOException {
/* 174 */     BufferedImage bufferedImage = ImageIO.read(inputStream);
/* 175 */     int i = bufferedImage.getWidth();
/* 176 */     int j = bufferedImage.getHeight();
/* 177 */     int[] arrayOfInt = getBufferImageData(bufferedImage);
/* 178 */     eos/moe/dragoncore/cu eos/moe/dragoncore/cu = new eos/moe/dragoncore/cu(bufferedImage, 1000, -1);
/* 179 */     this.l.add(eos/moe/dragoncore/cu);
/* 180 */     Minecraft.func_71410_x().func_152344_a(() -> {
/*     */           eos/moe/dragoncore/cu.v(eos/moe/dragoncore/cu1, TextureUtil.func_110996_a());
/*     */           updateDynamicTexture(eos/moe/dragoncore/cu.z(eos/moe/dragoncore/cu1), arrayOfInt, i, j);
/*     */         });
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public void loadGif(InputStream inputStream) throws IOException {
/* 189 */     List<Tuple<Integer, BufferedImage>> list = v(inputStream);
/*     */     
/* 191 */     int i = ((BufferedImage)((Tuple)list.get(0)).func_76340_b()).getWidth();
/* 192 */     int j = ((BufferedImage)((Tuple)list.get(0)).func_76340_b()).getHeight();
/* 193 */     for (Tuple<Integer, BufferedImage> tuple : list) {
/* 194 */       int[] arrayOfInt = getBufferImageData((BufferedImage)tuple.func_76340_b());
/* 195 */       eos/moe/dragoncore/cu eos/moe/dragoncore/cu = new eos/moe/dragoncore/cu((BufferedImage)tuple.func_76340_b(), ((Integer)tuple.func_76341_a()).intValue(), -1);
/* 196 */       this.l.add(eos/moe/dragoncore/cu);
/* 197 */       Minecraft.func_71410_x().func_152344_a(() -> {
/*     */             eos/moe/dragoncore/cu.v(eos/moe/dragoncore/cu1, TextureUtil.func_110996_a());
/*     */             updateDynamicTexture(eos/moe/dragoncore/cu.z(eos/moe/dragoncore/cu1), arrayOfInt, i, j);
/*     */           });
/*     */     } 
/*     */   }
/*     */   
/*     */   public int[] getBufferImageData(BufferedImage bufferedImage) {
/* 205 */     int[] arrayOfInt = new int[bufferedImage.getWidth() * bufferedImage.getHeight()];
/* 206 */     bufferedImage.getRGB(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), arrayOfInt, 0, bufferedImage.getWidth());
/* 207 */     return arrayOfInt;
/*     */   }
/*     */   
/*     */   public void updateDynamicTexture(int i, int[] arrayOfInt, int j, int k) {
/* 211 */     TextureUtil.func_110991_a(i, j, k);
/* 212 */     TextureUtil.func_110988_a(i, arrayOfInt, j, k);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public int func_110552_b() {
/* 234 */     if (this.f)
/* 235 */       return -1; 
/* 236 */     int i = -1;
/* 237 */     if (this.z != null) {
/* 238 */       i = super.func_110552_b();
/*     */     }
/* 240 */     if (this.l.size() > 0) {
/* 241 */       h();
/* 242 */       i = eos/moe/dragoncore/cu.z(this.l.get(this.t));
/*     */     } 
/*     */     
/* 245 */     return (i == -1) ? c.func_110552_b() : i;
/*     */   }
/*     */ 
/*     */   
/*     */   public void func_147631_c() {
/* 250 */     super.func_147631_c();
/* 251 */     for (eos/moe/dragoncore/cu eos/moe/dragoncore/cu : this.l) {
/* 252 */       if (eos/moe/dragoncore/cu.z(eos/moe/dragoncore/cu) != -1)
/* 253 */         TextureUtil.func_147942_a(eos/moe/dragoncore/cu.z(eos/moe/dragoncore/cu)); 
/*     */     } 
/*     */   }
/*     */   
/*     */   public nk toATextureCIItem() {
/* 258 */     if (this.l.size() > 0) {
/* 259 */       h();
/* 260 */       nk nk = new nk(this.r);
/* 261 */       nk.updateIcon(eos/moe/dragoncore/cu.v(this.l.get(this.t)));
/* 262 */       return nk;
/*     */     } 
/* 264 */     return null;
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public boolean isLoaded() {
/* 270 */     return this.s;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/* 286 */   public static hw w = new hw(""); public static boolean q; public static Map<String, eos/moe/dragoncore/xr> g;
/*     */   
/*     */   static {
/* 289 */     i = Executors.newCachedThreadPool(new vx());
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 340 */     g = new HashMap<>();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static void z() {
/*     */     i.shutdownNow();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static void v(String a) {
/*     */     GlStateManager.func_179144_i(v(a).func_110552_b());
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public List<eos/moe/dragoncore/cu> getImageList() {
/* 372 */     return this.l;
/*     */   }
/*     */   public static hw v(String a) { hw hw1; a = v(a); TextureManager textureManager = Minecraft.func_71410_x().func_110434_K(); ResourceLocation resourceLocation = new ResourceLocation("dragoncore", a); ITextureObject iTextureObject = textureManager.func_110581_b(resourceLocation); if (iTextureObject == null) { hw1 = new hw(a); textureManager.func_110579_a(resourceLocation, (ITextureObject)hw1); }  if (hw1 == TextureUtil.field_111001_a)
/*     */       hw1 = w;  return hw1; } public static ITextureObject v(String a) { hw hw1; a = v(a); TextureManager textureManager = Minecraft.func_71410_x().func_110434_K(); ResourceLocation resourceLocation = new ResourceLocation("dragoncore", a); ITextureObject iTextureObject = textureManager.func_110581_b(resourceLocation); if (iTextureObject == null) { hw1 = new hw(a); textureManager.func_110579_a(resourceLocation, (ITextureObject)hw1); }  if (hw1 == TextureUtil.field_111001_a)
/* 376 */       hw1 = w;  return (ITextureObject)hw1; } public int getImageIndex() { return this.t; }
/*     */ 
/*     */   
/*     */   public long getNextTime() {
/* 380 */     return this.d;
/*     */   }
/*     */   
/*     */   public void setImageList(List<eos/moe/dragoncore/cu> list) {
/* 384 */     this.l = list;
/*     */   }
/*     */   
/*     */   public void setImageIndex(int i) {
/* 388 */     this.t = i;
/*     */   }
/*     */   
/*     */   public void setNextTime(long l) {
/* 392 */     this.d = l;
/*     */   }
/*     */   
/*     */   public boolean isPlay() {
/* 396 */     return this.m;
/*     */   }
/*     */   
/*     */   public void setPlay(boolean bool) {
/* 400 */     this.m = bool;
/*     */   }
/*     */   
/*     */   public static class eos/moe/dragoncore/xr {
/*     */     public long i;
/*     */     private List<hw.eos/moe/dragoncore/yq> w;
/*     */     private long q;
/*     */     private int g;
/*     */     
/*     */     public eos/moe/dragoncore/xr(List<hw.eos/moe/dragoncore/yq> list) {
/* 410 */       this.i = System.currentTimeMillis();
/* 411 */       this.w = list;
/*     */     }
/*     */     
/*     */     public String v() {
/* 415 */       if (this.w.size() == 0)
/* 416 */         return "unknown.png"; 
/* 417 */       v();
/*     */       
/* 419 */       return hw.eos/moe/dragoncore/yq.v(this.w.get(this.g));
/*     */     }
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static class eos/moe/dragoncore/yq
/*     */   {
/*     */     private String q;
/*     */ 
/*     */ 
/*     */     
/*     */     private int g;
/*     */ 
/*     */ 
/*     */ 
/*     */     
/*     */     public eos/moe/dragoncore/yq(String str, int i) {
/* 439 */       this.q = str;
/* 440 */       this.g = i;
/*     */     }
/*     */   }
/*     */   
/*     */   public static class eos/moe/dragoncore/cu {
/*     */     private final BufferedImage w;
/*     */     private final int q;
/*     */     private int g;
/*     */     
/*     */     public eos/moe/dragoncore/cu(BufferedImage bufferedImage, int i, int j) {
/* 450 */       this.w = bufferedImage;
/* 451 */       this.q = i;
/* 452 */       this.g = j;
/*     */     }
/*     */     
/*     */     public BufferedImage v() {
/* 456 */       return this.w;
/*     */     }
/*     */     
/*     */     public int z() {
/* 460 */       return this.q;
/*     */     }
/*     */     
/*     */     public int v() {
/* 464 */       return this.g;
/*     */     }
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\hw.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */